package com.android.pI;

import java.util.*;
import android.database.Cursor;

public class Workout {

	// Data Fields
	private ArrayList<Exercise> theList;
	private int numEx;
	

	// Constructor
	public Workout(Cursor cursor) {
		theList = new ArrayList<Exercise>();
	
		for (cursor.moveToPosition(-1); cursor.moveToNext(); cursor.isAfterLast()) {
			int exerciseID2 = cursor.getInt(0);
			String exName2 = cursor.getString(1);
			Long exTime2 = cursor.getLong(2);
			String exImgae2 = cursor.getString(3);
			int exBest2 = cursor.getInt(4);
			theList.add(new Exercise(exerciseID2, exName2, exTime2, exImgae2, exBest2));
		}
	}

	public int getNumEx() {
		return numEx;
	}

	// Smell:
	// Bad code smell: The Dispensables (Dispensable Code)
	// In the Workout Class, the getfirst methods  are redundant and can be 
	// replaced by passing the position (0) to other methods.
	
	// Refactoring:
	// We will remove the getFirst methods and use getNext methods
	
/*	
   Old Code:
   
   public String getFirstName() {
		return theList.get(0).eName;
	}

	public Long getFirstTime() {
		return theList.get(0).eTime;
	}

	public String getNextName(int place) {

		return theList.get(place).eName;
	}

	public Long getNextTime(int place) {

		return theList.get(place).eTime;
	}
	
	New Code:
	
		public String getName(int place) {

		return theList.get(place).eName;
	}

	public Long getTime(int place) {

		return theList.get(place).eTime;
	}
	
*/	
	
	public String getName(int place) {

		return theList.get(place).eName;
	}

	public Long getTime(int place) {

		return theList.get(place).eTime;
	}
	
	public int getEID(int place) {
		return theList.get(place).exId ;
	}
	
	public int getBest(int place) {
		return theList.get(place).exBest ;
	}
	
	
	public String getImage(int n) {
		return theList.get(n).image;
	}

	public int size() {
		return theList.size();
	}

}
